home *** CD-ROM | disk | FTP | other *** search
Text File | 1995-12-01 | 2.3 KB | 100 lines | [TEXT/CWIE] |
- //
- // C3Lights.cp
- //
- // class C3Lights
- // Class for constructing a group consisting of 3 lights.
- //
- // Based on the "Start Here" sample code from Apple.
- //
- // by James Jennings
- // Started November 22, 1995
- //
-
- #include "C3Lights.h"
-
- #include <QD3DMath.h>
- #include <QD3DShader.h> // defines Q3ColorRGB_Set()
- #include <QD3DGroup.h> // defines Q3LightGroup_New()
-
- //
- // class CAmbient
- // constructs an ambient light
- //
- void
- C3Lights::CAmbient::Make()
- { // construct an ambient light
- TQ3LightData data;
-
- // generic light stuff: There is no location or direction.
- data.isOn = kQ3True;
- ::Q3ColorRGB_Set(&(data.color), 1.0, 1.0, 1.0); // White Light
- data.brightness = .2;
- mObject = ::Q3AmbientLight_New(&data);
- ThrowIfNil_(mObject);
- }
-
- //
- // class CPoint
- // constructs a point light source
- //
- void
- C3Lights::CPoint::Make()
- { // construct a point light source
- TQ3PointLightData data;
-
- // generic light stuff
- data.lightData.isOn = kQ3True;
- ::Q3ColorRGB_Set(&(data.lightData.color), 1.0, 1.0, 1.0); // White Light
- data.lightData.brightness = 1.0;
- // point light specific stuff: It has a location, but no direction
- data.castsShadows = kQ3False;
- data.attenuation = kQ3AttenuationTypeNone;
- ::Q3Point3D_Set( &(data.location), 10.0, 10.0, 10.0);
- mObject = ::Q3PointLight_New(&data);
- ThrowIfNil_(mObject);
- }
-
- //
- // class CFill
- // constructs a fill light source
- //
- void
- C3Lights::CFill::Make()
- { // construct a fill light
- TQ3DirectionalLightData data;
-
- // generic light stuff
- data.lightData.isOn = kQ3True;
- ::Q3ColorRGB_Set(&(data.lightData.color), 1.0, 1.0, 1.0); // White Light
- data.lightData.brightness = 0.2;
- // fill light specific stuff: it has direction, but no location
- data.castsShadows = kQ3False;
- ::Q3Vector3D_Set( &(data.direction), 10.0, 10.0, 10.0 );
- mObject = ::Q3DirectionalLight_New(&data);
- ThrowIfNil_(mObject);
- }
-
- //
- // class C3Lights
- // constructs a light group with three lights in it
- //
- void
- C3Lights::Make()
- { // make the group
- mObject = ::Q3LightGroup_New();
- ThrowIfNil_(mObject);
- // construct the three lights
- CAmbient ambient;
- CPoint point;
- CFill fill;
- // add the lights to the group
- TQ3GroupPosition pos;
- pos = ::Q3Group_AddObject(mObject, ambient.Get());
- ThrowIf_(pos==0);
- pos = ::Q3Group_AddObject(mObject, point.Get());
- ThrowIf_(pos==0);
- pos = ::Q3Group_AddObject(mObject, fill.Get());
- ThrowIf_(pos==0);
- }
-
-